package com.ljkj.common.db.dao;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ljkj.access.Tgroup;
import com.ljkj.access.Tuserrolerelation;
import com.ljkj.common.db.basedao.BaseDAO;

public class TUserRoleRelationDAO extends BaseDAO{

	private static final Logger log = LoggerFactory.getLogger(TUserRoleRelationDAO.class);
	// property constants
	public static final String POJONAME = "Tuserrolerelation";
	
	@Override
	protected void initDao() {
		// do nothingthis.setSessionFactory(sessionFactory);
	}

	public void save(Tuserrolerelation transientInstance) {
		log.debug("saving Tuserrolerelation instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void update(Tuserrolerelation tuserrolerelation) {
		log.debug("updating " + POJONAME + " instances");
		try {
			getHibernateTemplate().update(tuserrolerelation);
			log.debug("update successful");
		} catch (RuntimeException re) {
			log.error("update failed", re);
			throw re;
		}
	}

	public void delete(Tuserrolerelation tuserrolerelation) {
		log.debug("deleting Tuserrolerelation instance");
		try {
			getHibernateTemplate().delete(tuserrolerelation);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public Tuserrolerelation findById(java.lang.Integer id) {
		log.debug("getting Tuserrolerelation instance with id: " + id);
		try {
			Tuserrolerelation instance = (Tuserrolerelation) getHibernateTemplate().get(
					"com.ljkj.access.Tuserrolerelation", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(Tuserrolerelation instance) {
		log.debug("finding Tuserrolerelation instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance);
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding Tuserrolerelation instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from Tuserrolerelation as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}
	
	public List findAll() {
		log.debug("finding all Tuserrolerelation instances");
		try {
			String queryString = "from Tuserrolerelation";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	
}
